// ignore_for_file: must_be_immutable, prefer_typing_uninitialized_variables

import 'package:aitao_flutter/res/r.dart';
import 'package:aitao_flutter/style/box_style.dart';
import 'package:aitao_flutter/style/color_style.dart';
import 'package:aitao_flutter/style/radius_style.dart';
import 'package:aitao_flutter/style/text_style.dart';
import 'package:flutter/material.dart';

import '../model/personal_model.dart';

class ShowGuardAlert extends StatefulWidget {
  ShowGuardAlert({super.key, required this.guard, required this.guardCallBack});
  PersonalGuard guard;
  var guardCallBack;
  @override
  State<ShowGuardAlert> createState() => _ShowGuardAlertState();
}

class _ShowGuardAlertState extends State<ShowGuardAlert> {
  final _countList = [1, 10, 100];
  int guardIndex = 0;
  @override
  Widget build(BuildContext context) {
    return Center(
        child: Container(
            padding: const EdgeInsets.only(left: 30, right: 30, bottom: 24),
            margin: const EdgeInsets.only(left: 40, right: 40),
            decoration: const BoxDecoration(
                // color: ColorStyle.themeColor,
                gradient: LinearGradient(
                    begin: Alignment.topRight,
                    end: Alignment.bottomLeft,
                    colors: <Color>[Color(0xFFEBBBFF), Color(0xFFDCA0FF)]),
                borderRadius: BorderRadius.all(Radius.circular(10))),
            child: Stack(
              // fit: StackFit.expand,
              clipBehavior: Clip.none,
              alignment: Alignment.topCenter,
              children: [
                Container(
                  margin: const EdgeInsets.only(top: 110),
                  height: 240,
                  width: double.infinity,
                  // color: ColorStyle.orangeColor,
                  child: Column(
                    children: [
                      Text(
                        '守护',
                        style: Styles.whiteText_22,
                      ),
                      Box.vBox3,
                      Text(
                        '${widget.guard.guardPrice}阳光=1守护符',
                        style: Styles.whiteText_15,
                      ),
                      Box.vBox30,
                      Row(
                        mainAxisAlignment: MainAxisAlignment.spaceAround,
                        children: _countList.asMap().entries.map((e) {
                          return GestureDetector(
                            child: Container(
                              alignment: Alignment.center,
                              width: 65,
                              height: 35,
                              decoration: BoxDecoration(
                                  borderRadius: RadiusStyle.radiusAll(7),
                                  color: guardIndex == e.key
                                      ? const Color(0xFFFB6188)
                                      : ColorStyle.whiteColor),
                              child: Text(
                                e.value.toString(),
                                style: guardIndex == e.key
                                    ? Styles.whiteText_16
                                    : Styles.normalText_16,
                              ),
                            ),
                            onTap: () {
                              setState(() {
                                guardIndex = e.key;
                              });
                            },
                          );
                        }).toList(),
                      ),
                      Box.vBox30,
                      GestureDetector(
                        child: Container(
                          width: 190,
                          height: 44,
                          alignment: Alignment.center,
                          decoration: BoxDecoration(
                              borderRadius: RadiusStyle.radiusAll(8),
                              color: ColorStyle.whiteColor),
                          child: Text(
                            '守护TA',
                            style: Styles.normalText_16,
                          ),
                        ),
                        onTap: () {
                          Navigator.pop(context);
                          widget.guardCallBack(_countList[guardIndex]);
                        },
                      )
                    ],
                  ),
                ),
                Positioned(
                    top: -45,
                    child: Image.asset(
                      ImagePath.assetsGuardBtn,
                      width: 200,
                      height: 145,
                    )),
              ],
            )));
  }
}
